package com.caseProject.puremvc.mediator
{
	import com.caseProject.puremvc.mediator.view.MenuStateView;
	import com.caseProject.puremvc.mediator.events.MenuStateEvent;
	import com.caseProject.puremvc.notifications.NotificationNames;
	
	import flash.events.Event;
	
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	public class MenuStateMediator extends Mediator implements IMediator
	{
		public static const NAME:String = "StateMenuMediator";
				
		public function MenuStateMediator(viewComponent:MenuStateView)
		{
			super(NAME, viewComponent);
			
			this.stateMenuView.addEventListener(MenuStateEvent.CLICK_END, onEndClick);
			this.stateMenuView.addEventListener(MenuStateEvent.CLICK_NOTE, onNoteClick);
			this.stateMenuView.addEventListener(MenuStateEvent.CLICK_START, onStartClick);
			this.stateMenuView.addEventListener(MenuStateEvent.CLICK_STATE, onStateClick);
			this.stateMenuView.addEventListener(MenuStateEvent.CLICK_TRANSITION, onTransitionClick);
			this.stateMenuView.addEventListener(MenuStateEvent.CLICK_SELECT, onSelectClick);
		}
		
		public function get stateMenuView():MenuStateView
		{
			return viewComponent as MenuStateView;
		}
		
		protected function onSelectClick(event:Event):void
		{
			this.sendNotification(NotificationNames.STATE_MENU_IDLE);			
		}
		
		protected function onTransitionClick(event:Event):void
		{
			this.sendNotification(NotificationNames.STATE_MENU_TRANSITION);	
		}
		
		protected function onStateClick(event:Event):void
		{
			this.sendNotification(NotificationNames.STATE_MENU_STATE);
		}
		
		protected function onStartClick(event:Event):void
		{
			this.sendNotification(NotificationNames.STATE_MENU_START);
		}
		
		protected function onNoteClick(event:Event):void
		{
			this.sendNotification(NotificationNames.STATE_MENU_NOTE);
		}
		
		protected function onEndClick(event:Event):void
		{
			this.sendNotification(NotificationNames.STATE_MENU_END);	
		}
	}
}